<template>
	<view class="content">
		<view class="ll">
		<image src="../../static/images/index.png" mode=""></image>
		</view>
		<view class="loginBox">
			<view class="login-item">
				
				<image src="../../static/images/xiaoren.png" mode="aspectFit" class="phone"></image>
				<view class="uni-form-item uni-column"><input type="tel" class="uni-input" name="" placeholder="请输入手机号" v-model="phone"  /></view>
			</view>
			<view class="login-item">
				<image src="../../static/images/xiaosuo.png" mode="aspectFit" class="pwd"></image>
				<view class="uni-form-item uni-column"><input type="password" class="uni-input" name="" placeholder="请输入密码" v-model="possword" /></view>
			</view>
		</view>

		<view  class="login f34 cfff" @click="getLogin">登陆</view>
		<view class="forgetPwd tRight" @click="gotoPossword">忘记密码？</view>
		
		<view class="register tCenter f32 c666">
			还没有账号?<text @click="gotoForgetPassword">立即注册</text>
		</view>
	</view>
</template>

<script>
export default {
	data() {
		return {
			phone: '',
			possword: '',
			type:''
		};
	},
	onLoad() {},
	methods: {
	
		gotoForgetPassword() {
			uni.navigateTo({
				url: './registration'
			});
		},
		gotoPossword() {
			uni.navigateTo({
				url: './forget-password'
			});
		},
		getLogin() {
			if (!/^1[3456789]\d{9}$/.test(this.phone)) {
				uni.showToast({
					title: '请输入正确的手机号',
					duration: 2000,
					icon: 'none'
				});
				return;
			}else if(!/^\d{6}$/.test(this.possword)){
				uni.showToast({
					title: '密码输入不正确',
					duration: 2000,
					icon: 'none'
				});
				return;
			}
			this.$ajax('api/v1.user/login', {
				username: this.phone,
				password: this.possword
			})
				.then(res => {
					const { code, result } = res;
					if (code == 1) {
						uni.clearStorage()
						uni.setStorageSync('userinfo', result);
						this.$sToast('登陆成功');
// console.log(1);

						this.$ajax('api/v1.shop/index', {
							
						}, 'GET').then(res => {
					
						   const type=res.result.shop_info.name
								if(type==''){
									uni.navigateTo({
										url: '../shopMall/shopinfo',
										icon: 'none'
									})
									// setTimeout(function() {
									// 	uni.navigateTo({
									// 		url: '../shopMall/shopinfo',
									// 		icon: 'none'
									// 	})
									// }, 1500)
								}else{
									uni.switchTab({
										url: '../shop/index',
										icon: 'none'
									});
									// setTimeout(function() {
									// 	uni.switchTab({
									// 		url: '../shop/index',
									// 		icon: 'none'
									// 	});
									// }, 1500);
								}
						});

					
					} else {
						console.log(res);
						console.log(2);
					}
				}).catch(res => {
					console.log(error);
				});
		}
	}
};
</script>

<style lang="scss" scoped>
page {
	width: 100%;
	height: 100%;
}
.content {
	
	i {
		font-size: 96rpx;
		color: #ffffff;
		font-weight: 900;
		margin-bottom: 140rpx;
		text-align: center;
	}
}
.logo {
	text-align: center;
	image {
		height: 200rpx;
		width: 200rpx;
		margin: 0 0 60rpx;
	}
}
.loginBox{
	width: 100%;
	padding: 65upx 50upx 0 50upx;
	box-sizing: border-box;
	overflow: hidden;
	.login-item{
		display: flex;
		flex-direction: row;
		align-items: center;
		margin-bottom: 50upx;
		.phone{
			width: 40upx;
			height: 44upx;
			margin-top: 5upx;
		
		}
		.pwd{
			width: 38upx;
			height: 46upx;
			margin-top: 5upx;
	
		 
		}
	}
}
.uni-form-item {
	width: 100%;
	border-bottom: 1rpx solid #ddd;
	margin-left: 30upx;
	.uni-input {
		font-size: 30rpx;
		padding: 7rpx 0;
		
	}
}
button[type='primary'] {
	background-color: #128ef9;
	border-radius: 0;
	font-size: 34rpx;
	margin-top: 60rpx;
	width: 663rpx;
	height: 91rpx;
	border-radius: 999rpx;
}
.links {
	text-align: center;
	font-size: 26rpx;
	color: #128ef9;
	display: flex;
	justify-content: space-around;
	margin-top: 323rpx;

	view {
		display: inline-block;
		vertical-align: top;
		margin: 0 10rpx;
	}
	.link-highlight {
	}
}
.logo {
	margin-bottom: 60rpx;
}
.ll {
	height: 536rpx;
	width: 100%;
    
	image{
		width: 100%;
		height: 100%;
	}
	text-align: center;
}
.login{
	width: 670upx;
	margin: 35upx auto 0 auto;
	height: 85upx;
	line-height: 85upx;
	text-align: center;
	background: url(../../static/kitty-BasicLogin/loginBtn.png) no-repeat center;
	background-size: cover;
}
.forgetPwd{
	font-size: 28upx;
	color: #249AF6;
	padding: 25upx 50upx 0 0;
	}
	.register{
		display: flex;
		flex-direction: row;
		justify-content: center;
		margin: 320upx 0 100upx 0;
		text{
			color: #249AF6;
		}
	}
</style>
